/*
 *  Fighter.h
 *  
 *	Version 1.0
 *  Created by Nicholas Blecha on 9/20/10.
 *  Copyright 2010 Michigan Technological University. All rights reserved.
 *
 */


#ifndef FIGHTER_H
#define FIGHTER_H


#include "attacks.h"
#include "timer.h"
#include "logic.h"

enum Direction {
	FORWARD, NEUTRAL, BACKWARD, LEFT, RIGHT
};

class Fighter : public Sprite{
public:
	/*
	 * Returns a value representing the distance the fighter
	 * moves per frame
	 */
	int getSpeed();
	
	/*
	 * Returns a value representing the amount of damage the fighter's
	 * attacks can do.
	 */
	int getPower();
	
	/*
	 * Returns the maximum amount of hit points the fighter can have
	 */
	int getMaxHP();
	
	/*
	 * Returns the current amount of hit points the fighter has.
	 */
	int getHP();
	
	void setLives(int l) {
		lives = l;
	}
	
	int getLives() {
		return lives;
	}
	
	Renderer* getRenderer() {
		return rnd;
	}
	
	/*
	 * Reduces the fighter's hit points by the specified amount.
	 * Negative inputs result in increasing the fighter's hit points,
	 * but not above its maximum. Returns the fighter's HP after damage
	 * is calculated.
	 */
	int dmg(int d);
	
	void setMercy(double sec) {
		mercyCount = sec;
		mercyHide = true;
		mercyTimer.start();
	}
	
	bool isInMercyMode() {
		return (mercyCount > 0);
	}
	
	void setShielded(bool s) {
		shielded = s;
	}
	
	bool isShielded() { return shielded; }
	
	void turnLeft();
	void turnRight();	
	void accelerateForward();	
	void accelerateBackward();
	void brake();
	void stopTurn();
	float getAngle() {
		return angle;
	}
	/*
	 * Moves the fighter in a specified direction in an amount based on
	 * its speed value.
	 */
	void moveFighter(Uint32);
	
	Attack* getNormalAttack();
	
	void setNormalAttack(NormalAttack *n) {normal = n;}
	
	Attack* getWideAttack();
	
	void setWideAttack(WideAttack *w) {wide = w;}
	
	Attack* getSpecialAttack();
	
	void setSpecialAttack(SpecialAttack *s) {special = s;}
	
	Beam* getNewBeam();
	Beam* getBeam(int i);
	
	virtual void show(int mapX,int mapY);
	
	void setMapWidth(int w) {mapWidth = w;}
	void setMapHeight(int h) {mapHeight = h;}

	void setHP(int h){ hitPoints = h; };
	void setPos(int a, int b);
	
	bool respawn();
	void setRespawnPoint(int x, int y);
	void setRespawnPoint();
	
	int getLaserColor() {
		return defaultColor;
	}

	Fighter(int spd, int hp, int pwr);
	
	virtual ~Fighter();
	
protected:
	NormalAttack* normal;
	WideAttack* wide;
	SpecialAttack* special;
	
	void initializeBeams();
	void initializeExtras();
	
	int defaultColor;

	Logic			*logic;
private:
	Beam *controlledBeams[BEAM_LIMIT];
	
	double mercyCount;
	
	SDL_Surface *boost;
	GLuint boostID;
	
	SDL_Surface *shield;
	GLuint shieldID;
	
	SDL_Rect* initialPosition;
	
	bool shielded;

	int maxHitPoints;
	int hitPoints;
	int lives;
	int maxSpeed;
	int speed;
	int power;
	static const int stepsToFullSpeed = 20;
	static const int BLINK_MS_DELAY = 50;
	float rotationalVel;
	float maxRotVel;

	Timer mercyTimer;
	bool mercyHide;

	Direction forwardDir;
	Direction turnDir;

	Fighter();

	//keeps track of the width and height of the map for collision with the edge of the map
	int mapHeight;
	int mapWidth;
};

#endif
